//
//  WithDrawlRecordDetailViewModel.m
//  GLGW_Shoping
//
//  Created by whx on 2018/12/6.
//  Copyright © 2018年 yang. All rights reserved.
//

#import "WithDrawlRecordDetailViewModel.h"
#import "NoDataFootTableViewHeaderFooterView.h"
#import "WithDrawlRecordDetailTableViewCell.h"
#import "WithDrawRecordHeaderView.h"
#import "WithDrawlRecordFailuerTableViewCell.h"

@interface WithDrawlRecordDetailViewModel ()<UITableViewDelegate, UITableViewDataSource>
{
    UITableView *selfTableView;
    NSArray *leftArr;
    NSArray *headerArr;
}

@end

@implementation WithDrawlRecordDetailViewModel

- (instancetype)initWithViewToViewModel:(UITableView *)tableView theSuperView:(UIView *)superView
{
    if (self = [super initWithViewToViewModel:tableView theSuperView:superView]) {
        headerArr = @[@"基本信息", @"申请信息", @"审核信息"];
        leftArr = @[@[@"用户名", @"运营人", @"身份证号码"], @[@"申请提现金额", @"申请时间", @"提现至银行卡", @"银行卡卡号"], @[@"审核状态"]];
        tableView.delegate = self;
        tableView.dataSource = self;
        tableView.backgroundColor = [UIColor colorWithHexString:@"#F2F2F2"];
        tableView.sectionFooterHeight = 0.0;
        tableView.sectionHeaderHeight = 0.0;
        [tableView registerClass:[NoDataFootTableViewHeaderFooterView class] forHeaderFooterViewReuseIdentifier:@"NoDataFootTableViewHeaderFooterView"];
        [tableView registerClass:[WithDrawRecordHeaderView class] forHeaderFooterViewReuseIdentifier:@"WithDrawRecordHeaderView"];
        [superView addSubview:tableView];
        selfTableView = tableView;
    }
    return self;
}


- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 0.01;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return kHeightProportion_In_iPhoneTriploid(30);
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    WithDrawRecordHeaderView *headerView = [tableView dequeueReusableHeaderFooterViewWithIdentifier:@"WithDrawRecordHeaderView"];
    headerView.leftStr = headerArr[section];
    return headerView;
}

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
    NoDataFootTableViewHeaderFooterView *footer = [tableView dequeueReusableHeaderFooterViewWithIdentifier:@"NoDataFootTableViewHeaderFooterView"];
    return footer;
}

#pragma mark - tableViewDelegate
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return leftArr.count;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [leftArr[section] count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    WithDrawlRecordDetailTableViewCell *detailCell = [WithDrawlRecordDetailTableViewCell cellWithTableView:tableView];
    detailCell.leftStr = leftArr[indexPath.section][indexPath.row];
    if (indexPath.section == 0 && indexPath.row == 0) {

        NSString *str = @"北京泽人合网络科技有限公司 ";
        detailCell.rightLab.attributedText = [GLGWLabel addImageName:@"Shape" theImageFram:CGRectMake(0, -3, kWidthProportion_In_iPhoneTriploid(14), kHeightProportion_In_iPhoneTriploid(14)) theTextString:str atImageIndex:str.length];
        detailCell.rightLab.textAlignment = NSTextAlignmentRight;
    }
    NSString *colorStr = @"";
    if (indexPath.section == 1 && indexPath.row == 0) {
        colorStr = @"#EC5353";
    } else if (indexPath.section == 2 && indexPath.row == 0) {
        if (self.withDrawRecordType == WithDrawRecordType_ForWithdrawal) { // 待提现
            colorStr = @"#5DC061";
        } else if (self.withDrawRecordType == WithDrawRecordType_HaveWithdrawal) { // 已提现
            colorStr = @"#A89A60";
        } else if (self.withDrawRecordType == WithDrawRecordType_ToAudit) { // 待审核
            colorStr = @"#E3AF1B";
        } else if (self.withDrawRecordType == WithDrawRecordType_AuditFailure) { // 审核失败
            colorStr = @"##EC5353";
            WithDrawlRecordFailuerTableViewCell *fCell = [WithDrawlRecordFailuerTableViewCell cellWithTableView:tableView];
            fCell.rightLab.text =  @"水电费老师看见对方绿色减肥方绿色减肥方绿色减肥方绿色减肥绿色减肥方绿色减肥绿色减肥方绿色减肥绿色减肥路上看到就分手的李开复";
            return fCell;
        }

    } else {
        colorStr = @"#333333";
    }
    
    detailCell.rightLab.textColor = [UIColor colorWithHexString:colorStr];
    return detailCell;
}

@end
